Skip to content

Add Kubernetes namespace grouping support to Tilt UI#6736

Open
krishnactive wants to merge 2 commits intotilt-dev:masterfrom
krishnactive:feature/namespace-grouping-6632
Open

Add Kubernetes namespace grouping support to Tilt UI#6736
krishnactive wants to merge 2 commits intotilt-dev:masterfrom
krishnactive:feature/namespace-grouping-6632

Conversation

@krishnactive
Copy link
Copy Markdown
Contributor

Problem

Currently, resources in Tilt are not grouped by their Kubernetes namespace. This makes it difficult to:

  • See all resources related to a specific namespace together
  • Manage resources grouped by namespace
  • Restart all resources in a namespace at once

Resources like Services and Ingress are lumped under "unlabeled" instead of being grouped with their namespace's Pods and Deployments.

Solution

Expose namespace information from Kubernetes resources and provide utilities to group resources by namespace in the UI.

Backend Changes

  • UIResourceKubernetes: Added Namespace field to expose the K8s namespace
  • K8sRuntimeState: Added GetNamespace() method to extract namespace from DeployedRefs
  • convert.go: Populate namespace when creating UIResource objects

Frontend Changes

  • labels.ts: Added namespace grouping utilities:
    • getResourceNamespace() - Extract namespace from resource
    • resourcesHaveNamespaces() - Check if resources have namespace info
    • groupResourcesByNamespace() - Group resources by namespace
  • core.d.ts: Updated TypeScript types to include namespace field

How It Works

  1. Backend extracts namespace from K8s deployed references
  2. Namespace is exposed in UIResource data structure
  3. Frontend can now conditionally group resources by namespace
  4. Resources without namespace info are placed in "ungrouped" group

Example

After this change, resources will be organized like:

cert-manager (namespace)
  ├── cert-manager-controller (Pod)
  ├── cert-manager (Service)
  ├── cert-manager (Deployment)
  └── cert-manager (Ingress)

default (namespace)
  ├── my-app (Pod)
  ├── my-app (Service)
  └── my-app (Deployment)

Files Changed

  • pkg/apis/core/v1alpha1/uiresource_types.go - Added namespace field
  • internal/store/runtime_state.go - Added GetNamespace() method
  • internal/hud/webview/convert.go - Populate namespace in UIResource
  • web/src/labels.ts - Added namespace grouping functions
  • web/src/core.d.ts - Updated TypeScript types

Testing

  • ✅ Go backend compiles successfully
  • ✅ Go binary builds (v0.37.0-dev)
  • ✅ TypeScript compilation successful
  • ✅ Frontend build successful

Fixes #6632

When running 'tilt logs -f <resource>', build event logs from other
resources were incorrectly shown in the output. The resource filter
check was happening after the build event check, allowing build logs
to bypass resource filtering.

Solution: Reorder the filter checks in LogFilter.Matches() to apply
the resource filter first, before checking for build events. This
ensures all logs, including build events, respect the resource filter.

Fixes tilt-dev#6663
@krishnactive
Copy link
Copy Markdown
Contributor Author

krishnactive commented Apr 9, 2026

@nicks could u review this PR?

@nicks
Copy link
Copy Markdown
Member

nicks commented Apr 10, 2026

don't worry i'll get to it! i want to play with it on a couple projects

@nicks
Copy link
Copy Markdown
Member

nicks commented Apr 10, 2026

hmmm...i wasn't able to reproduce the behavior described in the pr description. the ui functions you added don't appear to be called anywhere?

krishnactive added a commit to krishnactive/tilt that referenced this pull request Apr 19, 2026
…OverviewTable

This completes the UI integration for namespace grouping (Issue tilt-dev#6632):

UI Components:
- Added SidebarGroupedByNamespace component in SidebarResources.tsx for sidebar grouping
- Added TableGroupedByNamespace component in OverviewTable.tsx for table grouping
- Both components group resources by namespace with "default" namespace shown first
- Ungrouped resources (without namespace or Tiltfile) are shown separately

SidebarItem Updates:
- Added resource property to SidebarItem to enable namespace access during grouping
- Allows UI components to extract namespace info directly from UIResource

Display Logic:
- Namespace grouping displays when no labels are present but namespaces exist
- Respects existing resource name filters (no grouping when filtered)
- Falls back to regular list view when neither labels nor namespaces are available

Fixes feedback from Jonas (PR tilt-dev#6736): namespace grouping functions are now actually used and rendered in the UI.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
krishnactive added a commit to krishnactive/tilt that referenced this pull request Apr 19, 2026
…OverviewTable

This completes the UI integration for namespace grouping (Issue tilt-dev#6632):

UI Components:
- Added SidebarGroupedByNamespace component in SidebarResources.tsx for sidebar grouping
- Added TableGroupedByNamespace component in OverviewTable.tsx for table grouping
- Both components group resources by namespace with 'default' namespace shown first
- Ungrouped resources (without namespace or Tiltfile) are shown separately

SidebarItem Updates:
- Added resource property to SidebarItem to enable namespace access during grouping
- Allows UI components to extract namespace info directly from UIResource

Display Logic:
- Namespace grouping displays when no labels are present but namespaces exist
- Respects existing resource name filters (no grouping when filtered)
- Falls back to regular list view when neither labels nor namespaces are available

Fixes feedback from Jonas (PR tilt-dev#6736): namespace grouping functions are now actually used and rendered in the UI.
@krishnactive krishnactive force-pushed the feature/namespace-grouping-6632 branch from 27952a8 to 5595526 Compare April 19, 2026 05:54
Complete implementation of Kubernetes namespace grouping in the UI:

Backend Implementation:
- Added Namespace field to UIResourceKubernetes struct
- Implemented GetNamespace() method in K8sRuntimeState
- Extract namespace from DeployedRefs in K8s resources
- Updated UIResource conversion to populate namespace field

Frontend Utilities:
- Added getResourceNamespace() to extract namespace from resources
- Added resourcesHaveNamespaces() to check if resources have namespace info
- Added groupResourcesByNamespace() to group resources by namespace

UI Component Integration:
- Added SidebarGroupedByNamespace component for sidebar resource grouping
- Added TableGroupedByNamespace component for table resource grouping
- Both components display resources grouped by Kubernetes namespace
- 'default' namespace shown first, others sorted alphabetically
- Ungrouped resources (without namespace info) shown separately

Display Logic:
- Namespace grouping displays when no labels are present but namespaces exist
- Respects resource name filters (no grouping when filtered)
- Falls back to regular list view when neither labels nor namespaces available
- Maintains full keyboard navigation and sorting support

Technical Details:
- Enhanced SidebarItem to store UIResource reference for namespace access
- Updated TypeScript types in core.d.ts to include namespace field
- Integrated gracefully with existing label-based grouping system
@krishnactive krishnactive force-pushed the feature/namespace-grouping-6632 branch from 5595526 to db9938b Compare April 19, 2026 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ability to group resources from k8s_yaml

2 participants